package com.demo.controller;

import com.demo.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author gatts, 2020/8/2 20:15
 */
@RestController
public class HelloController {

    @Autowired
    HelloService helloService;

    @RequestMapping("/")
    public String hello(){
        return helloService.sayHello();
    }

    /**
     * 配置了消息转换器，map会转成json字符串返回
     * @return
     */
    @RequestMapping(value = "/json", produces = "text/html;charset=utf-8")
    public Map json(){
        Map map = new HashMap();
        map.put("name", "小丸子");
        return map;
    }

}
